﻿

@model PagedList<ADZ_JingjiaMaster>
@{
    ViewBag.Title = "编辑竞价配置包";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    JingjiaQueryModel paramModel = new JingjiaQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (JingjiaQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();

}
@if (paramModel.jingjia_config_id > 0)
{
    var jingjia_config = dbcontext.ADZ_JingjiaConfig.FirstOrDefault(t => t.jingjia_config_id == paramModel.jingjia_config_id);

    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td style="width:350px">
                <h5>@ViewBag.Title   当前竞价配置【@jingjia_config.jingjia_config_name】包含以下竞价包</h5>
            </td>
            <td><button type="button" backpageid="jingjia/addconfig" class="btn btn-success" name="backid" id="backid">返回详情</button></td>
        </tr>
    </table>
    <table class="table table-bordered table-hover definewidth m10">
        <thead>
            <tr>
                <th>编号</th>
                <th style="text-align:center;vertical-align:middle;">竞价图片</th>
                <th>竞价包名称</th>
                <th>竞价状态</th>
                <th>是否含税</th>
                <th>起拍价</th>
                <th>加价幅度</th>
                <th>留置价</th>
                <th>延时周期</th>
                <th>拍卖类型</th>
                <th>结束时间</th>
                <th>出价次数</th>
                <th>围观次数</th>
                <th>最后出价时间</th>
                <th>最后出价金额</th>
                <th>操作</th>
            </tr>
        </thead>
        @{
            var jingjia_packages =
             from t in dbcontext.ADZ_JingjiaMaster
             where t.jingjia_config_id.Equals(paramModel.jingjia_config_id)
             select t;

            int index = 0;
            foreach (var m in jingjia_packages)
            {
                index++;
                <tr class="@HtmlPagerHelper.TrClass(index)">
                    <td>@m.jingjia_id</td>
                    <td style="text-align:center;vertical-align:middle;"><img src="@ImageFileBiz.GetImg(m.img_url,"small")" class="height20" /></td>
                    <td>@m.jingjia_name</td>
                    <td>
                        @if (m.jingjia_satus == 0)
                        {
                            <info>未开始</info>
                        }
                        else if (m.jingjia_satus == 1)
                        {
                            <info class="orange">竞价中</info>
                        }
                        else if (m.jingjia_satus == 2)
                        {
                            if (m.jingjia_deal_status == 2)
                            {
                                <info class="green">已成交</info>
                                var jingjiaSubmit = dbcontext.ADZ_JingjiaSubmit.FirstOrDefault(t => t.jingjia_id == m.jingjia_id && t.is_hit == 1);
                                if (jingjiaSubmit != null)
                                {
                                    if (jingjiaSubmit.status == 2)
                                    {
                                        <info class="red">未付款 <a href="/OrderMaster/OrderMasterInfo/@jingjiaSubmit.order_master_id">查看订单</a></info>
                                    }
                                    if (jingjiaSubmit.status == 10)
                                    {
                                        <info class="green">已付款 <a href="/OrderMaster/OrderMasterInfo/@jingjiaSubmit.order_master_id">查看订单</a></info>
                                    }
                                }
                            }
                            else
                            {
                                <info class="red">已流拍</info>
                            }
                        }
                    </td>
                    <td>
                        @if (m.include_tax == 1)
                        {
                            <info class="green">含税</info>
                        }
                        else
                        {
                            <info class="">未含税</info>
                        }
                    </td>
                    <td>@m.base_price.ToString("N2")</td>
                    <td>
                        @m.step_price.ToString("N2")
                        @if (m.step_price_max > 0)
                        {
                            <info> - @m.step_price_max.ToString("N2")</info>
                        }
                    </td>
                    <td>
                        @if (@m.liuzhi_price > 0)
                        {
                            <info>@m.liuzhi_price.ToString("N2")</info>
                        }
                    </td>
                    <td>@m.stay_miniutes 分钟/次</td>
                    <td>@m.jingjia_type</td>
                    <td>@m.real_end_time.ToString(1)</td>
                    <td>
                        <a href="/jingjia/ChujiaGetList?jingjia_id=@m.jingjia_id">@m.chujia_counts</a>
                    </td>
                    <td>@m.weiguan_counts</td>
                    <td>@m.last_time.ToString(1)</td>
                    <td>@m.last_price.ToString("N2")</td>
                    <td>
                        <a href="@Url.Action("add", "jingjia", new { id = m.jingjia_id})">查看</a>
                        <a href="javascript:void(0);" onclick="moveout(@m.jingjia_id)">移出</a>
                    </td>
                </tr>
            }
        }
    </table>
    <div class="inline pull-left total">
        总行数：@jingjia_packages.Count()
    </div>
}
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td colspan="2" style="width:50%">
            <h5>以下未配置到竞价配置中的竞价包可以添加到此竞价配置中 <info class="red">请谨慎操作</info></h5>
        </td>
    </tr>
</table>
<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("editconfigpackage", "jingjia")" method="get">
    <input type="hidden" value="@paramModel.jingjia_config_id" name="jingjia_config_id" />
    <div class="form_query">
        <div>
            编号：
            <input type="text" name="jingjia_id" id="jingjia_id" class="abc input-default" placeholder="" value="@paramModel.jingjia_id">&nbsp;
        </div>
        <div>
            竞价包名称：
            <input type="text" name="jingjia_name" id="jingjia_name" class="abc input-default" placeholder="" value="@paramModel.jingjia_name">&nbsp;
        </div>   
        <div>
            <button type="submit" class="btn btn-primary" id="formsubmit">查询</button>&nbsp;&nbsp;
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>编号</th>
            <th style="text-align:center;vertical-align:middle;">竞价图片</th>
            <th>竞价包名称</th>
            <th>竞价状态</th>
            <th>是否含税</th>
            <th>起拍价</th>
            <th>加价幅度</th>
            <th>留置价</th>
            <th>延时周期</th>
            <th>拍卖类型</th>
            <th>结束时间</th>
            <th>出价次数</th>
            <th>围观次数</th>
            <th>最后出价时间</th>
            <th>最后出价金额</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
            <tr class="@HtmlPagerHelper.TrClass(index)">
                <td>
                    <input type="checkbox" name="cbx_last" value="@m.jingjia_id" />@m.jingjia_id
                </td>
                <td style="text-align:center;vertical-align:middle;"><img src="@ImageFileBiz.GetImg(m.img_url,"small")" class="height20" /></td>
                <td>@m.jingjia_name</td>
                <td>
                    @if (m.jingjia_satus == 0)
                    {
                        <info>未开始</info>
                    }
                    else if (m.jingjia_satus == 1)
                    {
                        <info class="orange">竞价中</info>
                    }
                    else if (m.jingjia_satus == 2)
                    {
                        if (m.jingjia_deal_status == 2)
                        {
                            <info class="green">已成交</info>
                            var jingjiaSubmit = dbcontext.ADZ_JingjiaSubmit.FirstOrDefault(t => t.jingjia_id == m.jingjia_id && t.is_hit == 1);
                            if (jingjiaSubmit != null)
                            {
                                if (jingjiaSubmit.status == 2)
                                {
                                    <info class="red">未付款 <a href="/OrderMaster/OrderMasterInfo/@jingjiaSubmit.order_master_id">查看订单</a></info>
                                }
                                if (jingjiaSubmit.status == 10)
                                {
                                    <info class="green">已付款 <a href="/OrderMaster/OrderMasterInfo/@jingjiaSubmit.order_master_id">查看订单</a></info>
                                }
                            }
                        }
                        else
                        {
                            <info class="red">已流拍</info>
                        }
                    }
                </td>
                <td>
                    @if (m.include_tax == 1)
                    {
                        <info class="green">含税</info>
                    }
                    else
                    {
                        <info class="">未含税</info>
                    }
                </td>
                <td>@m.base_price.ToString("N2")</td>
                <td>
                    @m.step_price.ToString("N2")
                    @if (m.step_price_max > 0)
                    {
                        <info> - @m.step_price_max.ToString("N2")</info>
                    }
                </td>
                <td>
                    @if (@m.liuzhi_price > 0)
                    {
                        <info>@m.liuzhi_price.ToString("N2")</info>
                    }
                </td>
                <td>@m.stay_miniutes 分钟/次</td>
                <td>@m.jingjia_type</td>
                <td>@m.real_end_time.ToString(1)</td>
                <td>
                    <a href="/jingjia/ChujiaGetList?jingjia_id=@m.jingjia_id">@m.chujia_counts</a>
                </td>
                <td>@m.weiguan_counts</td>
                <td>@m.last_time.ToString(1)</td>
                <td>@m.last_price.ToString("N2")</td>
                <td>
                    <a href="@Url.Action("add", "jingjia", new { id = m.jingjia_id})">查看</a>
                    <a href="javascript:void(0);" onclick="movein(@m.jingjia_id)">加入竞价配置</a>
                </td>
            </tr>
        }
        <tr>
            <td colspan="20">
                <a href="javascript:void(0);" onclick="movemorein()">选择项加入竞价包</a>
            </td>
        </tr>
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    var cancelButton =
        {
            text: '取消',
            elCls: 'button',
            handler: function () {
                this.close();
            }
        };
    reloadHandler = function () {
        window.location.reload();
    };
    function moveout(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要将该竞价包移出此配置吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("doeditjingjiapackage", "jingjia")";
                      parameter = {
                          inout:1,//1移除 2 加入
                          jingjia_id: id,
                          jingjia_config_id: @paramModel.jingjia_config_id
                      };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
                },
                cancelButton
            ]
        });
    }
    function movein(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要将该竞价包加入此配置吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("doeditjingjiapackage", "jingjia")";
                      parameter = {
                          inout : 2,
                          jingjia_id: id,
                          jingjia_config_id: @paramModel.jingjia_config_id
                      };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
                },
                cancelButton
            ]
        });
    }
    function movemorein() {
        var ids = getCheckboxList();
        if (ids.length == 0) {
            BUI.Message.Alert("请选择要加入竞价配置的数据", 'warning');
            return;
        }
        BUI.Message.Show({
            title: '提示',
            msg: '确定要将选择的竞价包都加此配置吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("doeditjingjiapackagemore", "jingjia")";
                      parameter = {
                            inout : 2,
                          jingjia_config_id: @paramModel.jingjia_config_id,
                          jingjia_ids: ids
                      };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
              },
                cancelButton

            ]
        });
    }
</script>
